# -*- coding: utf-8 -*-
from flask import make_response, jsonify
from flask_hsrpc.__version__ import __version__ as hsrpc_version

from . import rpc


@rpc.route(methods=["GET"], description="Health Check")
def health():
    return {
        "hsrpcVersion": hsrpc_version,
        "status": "ok"
    }


@rpc.route(methods=["GET"], description="swagger api doc json")
def apidocs():
    rst = make_response(jsonify(rpc.swagger.to_dict()))
    rst.headers['Access-Control-Allow-Origin'] = '*'
    rst.headers['Access-Control-Allow-Methods'] = 'GET'
    allow_headers = "Referer,Accept,Origin,User-Agent"
    rst.headers['Access-Control-Allow-Headers'] = allow_headers
    return rst
